function wxpay(app, amount_total, orderNumber, redirectUrl,status,orderId,md5) {
	let remark = "在线充值";
	let nextAction = {};
  console.log(orderId);
  console.log(111111);
//	if (orderId != 0) {
//		remark = "支付订单 ：" + orderId;
//		nextAction = { type: 0, id: orderId };
//	}
  
	wx.request({
		url: app.globalData.payUrl,
		data: {
			open_id: app.globalData.openIdPay,
      amount_total: amount_total,
			user_order_name: orderNumber,
			pay_type: 'shop',
      backup:'shop_user'
		},
		header: {
			"Content-Type": "application/x-www-form-urlencoded"
		},
		//method:'POST',
		success: function(res){
			if(res.data.code == 0){
				// 发起支付
				wx.requestPayment({
					timeStamp:res.data.data.timeStamp,
					nonceStr:res.data.data.nonceStr,
					package:'prepay_id=' + res.data.data.prepayId,
					signType:'MD5',
					paySign:res.data.data.sign,
					fail:function (aaa) {
						wx.showToast({title: '支付失败'})
					},
					success:function () {
            if(status=='product'){
             var jsonObj = '{"order_id":' + orderId+'}';
  
             var params = jsonObj;
              console.log(params);
              var service = 'Erp.sendMqTask';
              var method = 'createOrder'
              var sign = md5.md5(method + params + service);
              wx.request({
                url: app.globalData.serviceUrl + 'Erp.sendMqTask',
                header: {
                  'Content-Type': 'json'
                },
                data: {
                  sign: sign,
                  params: params,
                  method: method,
                },
                success: function (res2) {
                  console.log(res2);
                }
              })
            }
						wx.showToast({title: '支付成功'})
						wx.redirectTo({
							url: redirectUrl
						});
            console.log(orderId);
            console.log(22222);
            var openidPay = app.globalData.openIdPay
            var formId = res.data.data.prepayId
            var order_id = orderId
            var service_1 = 'Order.ChangeOrder'
            var sign_1 = md5.md5(formId + openidPay + order_id + service_1)
            wx.request({
              url: app.globalData.serviceUrl + 'Order.ChangeOrder',
              header: {
                'Content-Type': 'json'
              },
              data: {
                sign: sign_1,
                openidPay: openidPay,
                formId: formId,
                order_id: order_id
              },
              success: function (res3) {
                console.log(res3);
              }
            })
					},
					complete: function(res) {
						console.log(res);
					},
				})
			} else {
				wx.showToast({ title: '服务器忙' + res.data.code + res.data.msg})
			}
		},
		complete: function(res) {
			console.log(res);
		},
	})
}

module.exports = {
		wxpay: wxpay
}
